package com.huiquan.section.dao;

import java.util.HashMap;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Repository;

import com.huiquan.analysis.domain.User;
import com.huiquan.framework.base.EnhancedBaseDao;
import com.huiquan.section.domain.Section;
import com.ibatis.sqlmap.client.SqlMapClient;

@Repository
public class SectionDao extends EnhancedBaseDao<Section> {

	@Resource(name = "sqlMapClient")
	private SqlMapClient sqlMapClient;

	public static final String space = "SECTION.";

	public SectionDao() {
		super(space);
	}

	public void setSex(String id, String sex, User user) {
		Map<String, Object> param = new HashMap<>();
		param.put("id", id);
		param.put("sex", sex);
		param.put("userId", user.getUserId());
		this.update(space + "SET_SEX", param, sqlMapClient);
	}

	public void setAge(String id, String age, User user) {
		Map<String, Object> param = new HashMap<>();
		param.put("id", id);
		param.put("age", age);
		param.put("userId", user.getUserId());
		this.update(space + "SET_AGE", param, sqlMapClient);
	}

	public void submitSexAge(String ids, User user) {
		Map<String, Object> param = new HashMap<>();
		param.put("ids", "(" + ids + ")");
		param.put("userId", user.getUserId());
		this.update(space + "SUBMIT_SEX_AGE", param, sqlMapClient);
	}
	
	
	public void deleteSectionInvalid() {
		this.update(space + "DELETE_SECTION_INVALID",  sqlMapClient);
	}
}
